package cn.edu.baiyunu.myapplication.ui.home

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.lifecycle.viewmodel.compose.viewModel
import cn.edu.baiyunu.myapplication.data.db.entity.PhotoRecord
import cn.edu.baiyunu.myapplication.data.model.PhotoSpec
import cn.edu.baiyunu.myapplication.ui.components.BottomNavigationBar
import cn.edu.baiyunu.myapplication.ui.components.PatternDotsBackground
import cn.edu.baiyunu.myapplication.ui.components.TopAppBar

/**
 * 首页屏幕组件 - 按照原型图设计
 */
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun HomeScreen(
    viewModel: HomeViewModel,
    onNavigateToUpload: () -> Unit,
    onNavigateToSpecs: () -> Unit,
    onNavigateToHistory: () -> Unit,
    onPhotoClick: (PhotoRecord) -> Unit,
    onSpecClick: (PhotoSpec) -> Unit,
    onNotificationClick: () -> Unit,
    onSettingsClick: () -> Unit
) {
    val snackbarHostState = remember { SnackbarHostState() }
    
    Box(
        modifier = Modifier
            .fillMaxSize()
            .background(Color(0xFFF8FAFC)) // 背景色
    ) {
        // 添加图案背景
        PatternDotsBackground()
        
        // 主要内容
        Scaffold(
            topBar = {
                TopAppBar(
                    onNotificationClick = onNotificationClick,
                    onSettingsClick = onSettingsClick
                )
            },
            snackbarHost = { SnackbarHost(snackbarHostState) },
            containerColor = Color.Transparent // 使Scaffold背景透明
        ) { innerPadding ->
            HomeContent(
                viewModel = viewModel,
                paddingValues = innerPadding,
                onNavigateToUpload = onNavigateToUpload,
                onNavigateToSpecs = onNavigateToSpecs,
                onNavigateToHistory = onNavigateToHistory,
                onPhotoClick = onPhotoClick,
                onSpecClick = onSpecClick
            )
        }
    }
} 